package com.lr.springbootmybatisdemo.controller;

import com.lr.springbootmybatisdemo.entity.MallUser;
import com.lr.springbootmybatisdemo.service.MallUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (MallUser)表控制层
 *
 * @author makejava
 * @since 2021-10-24 13:59:04
 */
@RestController
@RequestMapping("mallUser")
public class MallUserController {
    /**
     * 服务对象
     */
    @Resource
    private MallUserService mallUserService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public MallUser selectOne(Integer id) {
        return this.mallUserService.queryById(id);
    }

    /**
     * 根据条件查询
     * @param mallUser
     * @return
     */
    @GetMapping("selectAll")
    public List<MallUser> queryAll(MallUser mallUser) {
        return mallUserService.queryAll(mallUser);
    }


    /**
     * 新增一个用户
     * @param user
     * @return
     */
    @PostMapping("insertOne")
    public MallUser insertOne(@RequestBody MallUser user) {
        return mallUserService.insert(user);
    }

    /**
     * 修改数据
     * @param user
     * @return
     */
    @PutMapping("updateOne")
    public MallUser updateOne(@RequestBody MallUser user) {
        return mallUserService.update(user);
    }

    /**
     * 删除一个用户
     * @param id
     * @return
     */
    @DeleteMapping("deleteOne")
    public Boolean deleteOne(Integer id ) {
        return mallUserService.deleteById(id);
    }






}